import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';

class CourseListItem extends StatelessWidget {
  const CourseListItem({
    super.key,
    this.name = '',
    this.address = '',
    this.distance = '',
    this.onTap,
    this.image = ''
  });
  // 名称
  final String name;
  // 地址
  final String address;
  // 距离
  final String distance;

  final String image;

  final Function? onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        onTap?.call();
      },
      child: Container(
        padding: EdgeInsets.symmetric(vertical: 12.w),
        child: Row(
          children: [
            Container(
              width: 110.w,
              height: 88.w,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10.r),
              ),
              child: ClipRRect(
                borderRadius: BorderRadius.circular(10.r),
                child: Image.network(image, fit: BoxFit.fill, excludeFromSemantics: true, gaplessPlayback: true,),
              ),
            ),
    
            SizedBox(width: 10.w,),
    
            Container(
              height: 88.w,
              padding: EdgeInsets.only(top: 8.w, bottom: 7.w),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  SizedBox(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(
                          width: 220.w,
                          child: Text(name, style: TextStyle(fontSize: 15.sp, fontWeight: FontWeight.w500), maxLines: 1, overflow: TextOverflow.ellipsis,),
                        ),
                        SizedBox(height: 4.w,),
                        SizedBox(
                          width: 220.w,
                          child: Text(address, style: TextStyle(fontSize: 12.sp, color: const Color(0xff666666)), maxLines: 2, overflow: TextOverflow.ellipsis,),
                        ),
                      ],
                    ),
                  ),
    
                  const Spacer(),
    
                  SizedBox(
                    child: Row(
                      children: [
                        SizedBox(
                          width: 10.w,
                          height: 10.w,
                          child: Image.asset('assets/images/img_lise_dw.png'),
                        ),
    
                        SizedBox(width: 6.w,),
    
                        SizedBox(
                          child: Text(distance, style: TextStyle(fontSize: 11.sp, color: const Color(0xff999999)),),
                        )
                      ],
                    ),
                  )
                ],
              ),
            )
          ],
        ),
      ),
    );
  }
}